{% extends 'PortalMainBundle::layout.html.twig' %}

{% block stylesheets %}
  {{ parent() }}
{% endblock %}
{% block javascripts %}
<script src="{{ asset('js/jquery.js') }}" type="text/javascript"></script>

<script>
  
$(document).ready(function() {
  
  $('#contractContent').val('');
  
});
  
function checkboxCheck() {
  
  if ($("#checkbox").attr('checked')=='checked') {    
      $("#submitButton").removeAttr('disabled');
  } else {
    $("#submitButton").attr('disabled', 'disabled');
  } 
  
  if ($('#checkbox').is(':checked')) {
      $("#submitButton").removeAttr('disabled');
  } else {
     $("#submitButton").attr('disabled', 'disabled');
  }
}



function validate(form) {
  
  var contractHTML = $('#contentId').html();      
  $('#contractContent').val(contractHTML);

  var valid = true;

  // validation code here ...

  if(!valid) return false;
  else return confirm('Та хичээл заах үүсгэхдээ итгэлтэй байна уу?');
}

</script>
{% endblock %}


{% block content %}
  {% render 'PortalContractBundle:Contract:showContractByComponent' with {'contractId' : contractId} %}
  {% if block is null %}
  <div>
    <form action="{{path('contractUserSubmit')}}" method="POST" onsubmit="return validate(this);">
      <label>Та веб сайтын нөхцөлийг зөвшөөрч байна уу? <input type="checkbox" onclick="checkboxCheck()" name="agreement" id="checkbox" value="1"/> </label>

      <input type="hidden" name="contractId" value="{{contractId}}" />
      <input type="hidden" name="contractContent" id="contractContent" value="" />

      <input type="submit" name="agree" id="submitButton" value="Зөвшөөрч байна" disabled="disabled">
      <input type="submit" name="disagree" id="cancel" value="Татгалзаж байна">
    </form>
  </div>
  {% elseif block == 1 %}
  <div>
    <form action="{{path('contractFirstLesson')}}" method="POST" onsubmit="return validate(this);">
      <label>Анхны хичээл орсон та үргэлжлүүлэхийг хүсэж байна уу? <input type="checkbox" onclick="checkboxCheck()" name="agreement" id="checkbox" value="1"/> </label>

      <input type="hidden" name="contractId" value="{{contractId}}" />
      <input type="hidden" name="contractContent" id="contractContent" value="" />

      <input type="submit" name="firstLessonAgree" id="submitButton" value="Зөвшөөрч байна" disabled="disabled">
      <input type="submit" name="firstLessonDisagree" id="cancel" value="Татгалзаж байна">
    </form>
  </div>
    {% endif %}
{% endblock %}